<?php
if(!function_exists("get_include_contents")) {
	function get_include_contents($filename,$data='') {
	    if (is_file($filename)) {
	    	if (is_array($data)){
			extract($data);
	    	}
	        ob_start();
	        include $filename;
	        $contents = ob_get_contents();
	        ob_end_clean();
	        return $contents;
	    }
	    return false;
	}
}
if(!function_exists("add_include_path")) {
	function add_include_path ($path)
	{
	    foreach (func_get_args() AS $path)
	    {
	        if (!file_exists($path) OR (file_exists($path) && filetype($path) !== 'dir'))
	        {
	            trigger_error("Include path '{$path}' not exists", E_USER_WARNING);
	            continue;
	        }
	       
	        $paths = explode(PATH_SEPARATOR, get_include_path());
	       
	        if (array_search($path, $paths) === false)
	            array_push($paths, $path);
	       
	        set_include_path(implode(PATH_SEPARATOR, $paths));
	    }
	}
}
if(!function_exists("remove_include_path")) {
	function remove_include_path ($path)
	{
	    foreach (func_get_args() AS $path)
	    {
	        $paths = explode(PATH_SEPARATOR, get_include_path());
	       
	        if (($k = array_search($path, $paths)) !== false)
	            unset($paths[$k]);
	        else
	            continue;
	       
	        if (!count($paths))
	        {
	            trigger_error("Include path '{$path}' can not be removed because it is the only", E_USER_NOTICE);
	            continue;
	        }
	       
	        set_include_path(implode(PATH_SEPARATOR, $paths));
	    }
	}
}

if(!function_exists('get_called_class')) {
        class class_tools {
                static $i = 0;
                static $fl = null;

                static function get_called_class() {
                    $bt = debug_backtrace();

                        if (self::$fl == $bt[2]['file'].$bt[2]['line']) {
                            self::$i++;
                        } else {
                            self::$i = 0;
                            self::$fl = $bt[2]['file'].$bt[2]['line'];
                        }

                        $lines = file($bt[2]['file']);

                        preg_match_all('/([a-zA-Z0-9\_]+)::'.$bt[2]['function'].'/',
                            $lines[$bt[2]['line']-1],
                            $matches);

                return $matches[1][self::$i];
            }
        }

        function get_called_class() {
            return class_tools::get_called_class();
        }
}